package com.tsingtree.config.datasource;

import com.tsingtree.base.auth.context.LoginContextHolder;
import com.tsingtree.trees.core.metadata.CustomMetaObjectHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class PluginsConfig {

    @Bean
    public CustomMetaObjectHandler mpFieldHandler() {
        return new CustomMetaObjectHandler() {

            @Override
            protected Long getUserUniqueId() {
                try {
                    return LoginContextHolder.getContext().getUser().getId();
                } catch (Exception e) {
                    return -100L;
                }
            }
        };
    }

}
